<!doctype html>
<html lang="en" class="fullscreen-bg">

<head>
	<title>登录</title>
	<meta charset="utf-8">
	<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
	<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0">
	<!-- VENDOR CSS -->
	<link rel="stylesheet" href="../../static/assets/css/bootstrap.min.css">
	<link rel="stylesheet" href="../../static/assets/vendor/font-awesome/css/font-awesome.min.css">
	<link rel="stylesheet" href="../../static/assets/vendor/linearicons/style.css">
	<!-- MAIN CSS -->
	<link rel="stylesheet" href="../../static/assets/css/main.css">
	<!-- FOR DEMO PURPOSES ONLY. You should remove this in your loan -->
	<link rel="stylesheet" href="../../static/assets/css/demo.css">
	<link rel="stylesheet" href="../../static/assets/css/zeroModal.css">

	<!-- GOOGLE FONTS -->
	<!-- <link href="../../static/assets/fonts/googleapi.css?family=Source+Sans+Pro:300,400,600,700" rel="stylesheet"> 
	-->
	<link href="../../static/assets/fonts/googleapi.css?family=Source+Sans+Pro:300,400,600,700" rel="stylesheet"> 
	
	<!-- ICONS -->
	<link rel="apple-touch-icon" sizes="76x76" href="../../static/assets/img/apple-icon.png">
	<link rel="icon" type="image/png" sizes="96x96" href="../../static/assets/img/favicon.png">
</head>

<body style="">
	<!-- WRAPPER -->
	<div id="wrapper">
		<div class="vertical-align-wrap">
			<div  class="vertical-align-middle bgpic">
				 <div class="auth-box " style="width: 500px;padding: 30px;">
					<!-- <div class="left"> -->
						<div class="content"> <!-- style="margin-top: -420px;" -->
							<div class="header">
								<div class="logo text-center"><img src="../../static/assets/img/slogo-dark.png" alt="Klorofil Logo"></div>
								<p class="lead">请登录到您的账户</p>
							</div>
							<form class="form-auth-small">
								<div class="form-group">
									<label for="username" class="control-label sr-only">用户名</label>
									<input type="text" class="form-control" id="username"  placeholder="用户名">
								</div>
								<div class="form-group">
									<label for="password" class="control-label sr-only">密码</label>
									<input type="password" class="form-control" id="password" placeholder="密码">
								</div>
								
								<div class="form-group clearfix">
									<label class="fancy-checkbox element-left">
										<input type="checkbox" name="rememberMe" id="rememberMe">
										<span>记住我</span>
									</label>
								</div>
								<input type="hidden" class="form-control" id="captchaz" value="ZzZzZzZz" placeholder="验证码">
								<!-- <div class="form-group">
										<label for="captchaz" class="control-label sr-only">验证码</label>
										<div class="row">
											<div class="col-md-8">
													<input type="text" class="form-control" id="captchaz" placeholder="验证码">
											</div>
											<div class="col-md-4">
												<img alt="" id="captcha" style="height: 35px;width: 100%" onclick="refreshCaptcher();" src="http://124.128.220.213:86/api/auth/captcha?88" style="display: inline;">
											</div>
										</div>

									</div> -->
									<p id="error_show"></p>
								<!-- <div class="form-group clearfix">
									<label class="fancy-checkbox element-left">
										<input type="checkbox">
										<span>记住我</span>
									</label>
								</div> -->
								<button id="doLogin"  class="btn btn-primary btn-lg btn-block">登陆</button>
							</form>
						</div>
					</div>
			</div>
		</div>
	</div>
	<!-- END WRAPPER -->
</body>
<script src="../../static/assets/vendor/jquery/jquery.min.js"></script>
<script src="../loan/scripts/jquery-md5.min.js"></script>
<script src="../../static/js/jquery.cookie.js"></script>

<script src="../../static/assets/scripts/zeroModal.min.js"></script>

<script src="../../static/assets/scripts/admin.js"></script>

<script>

		document.getElementById('doLogin').addEventListener('click', function (ev) {
			ev.preventDefault();
		  dologin();
		})
	
		function dologin(){
			 var rememberMe=$("input[id='rememberMe']").is(':checked');
			
		  var username = $.trim($("#username").val());
		  var password = $.trim($("#password").val());
		  var captcha = $.trim($("#captchaz").val());
		  if(username.length < 1){
			$("#error_show").empty();
			$("#error_show").html("<font color=\"red\">请输入用户名</font>");
			return;
		  }
		  if(password.length < 3){
			//$("#username").empty();
			//$("#password").empty();
			$("#password").val();
			$("#error_show").empty();
			$("#error_show").html("<font color=\"red\">请输入密码</font>");
			$("#password").focus();
			return;
		  }
		  if(captcha.length <3){
			//$("#username").empty();
			//$("#password").empty();
			$("#captchaz").val();
			$("#error_show").empty();
			$("#error_show").html("<font color=\"red\">请输入验证码</font>");
			$("#captchaz").focus();
			return;
		  }
	
		  password=convertPassword(username,password);
		  console.log("password:"+password);
	
		  var param = { "username" : username,"password":password,"captcha":"验证码符号","loginOrgin":"PC","rememberMe":rememberMe};
	
		  request({
			url: API_DOMAIN + '/api/auth/jwt/login',
			data: param,
			success: function (result) {
				
				doSaveCookie();
				refreshCaptcher();
			  if(result.statusCode === 200) {
					token_st=result.data.snowier_st;
					localStorage.setItem("token_st",token_st);
					goUrl('./index.html')
			  } else {
				  refreshCaptcher();
					zeroModal.alert(result.message);
			  }
			}
		  })
		}
	
		function convertPassword(username,password){
		  var salt="zhtframework_94DABGioQOq2tTUO0AXYow";
		  return hex_md5(salt+password);
		}
	
		function refreshCaptcher(){
		  $('#captcha').hide().attr('src', API_DOMAIN + 'api/auth/captcha?' + Math.floor(Math.random()*100) ).fadeIn();
		}
	function doSaveCookie(){
		var rememberMe=$("input[id='rememberMe']").is(':checked');
		if (rememberMe==true) {
			var username = $.trim($("#username").val());
			$.cookie("rmbUser", "true", {expires : 7}); 
			$.cookie("username", username, {expires : 7}); 
		}else{
			$.removeCookie("rmbUser"); 
			$.removeCookie("username"); 
		}
		
	}
		$(function(){
			if ($.cookie("rmbUser")=="true") {
				$("#rememberMe").attr("checked", "checked");
				$("#username").val($.cookie("username"));
			}
		  refreshCaptcher();
		});
	  </script>
</html>
